using ASP;
using HoWave.Web;
using HoWave.Web.Shop;
using System;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI.WebControls;
public class Shop_Auction_Replay_Product_Msg : Shop, IRequiresSessionState
{
	protected Literal SenderName;
	protected Literal Request_date;
	protected Literal Request_Text;
	protected TextBox MsgArea;
	protected TextBox CheckCode;
	protected Button Submit;
	protected HyperLink login;
	protected Label err_tips;
	protected HiddenField h_productname;
	protected HiddenField h_product_id;
	protected HiddenField h_saler_id;
	protected HiddenField h_saler_nickname;
	protected HiddenField H_RequestType;
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		if (base.Request.RawUrl.Contains("Replay_Product_Msg.aspx"))
		{
			this.H_RequestType.Value = "Request";
		}
		if (!base.user.CheckUserLogin())
		{
			this.login.Text = "你要先登录才能回复";
			this.login.NavigateUrl = "Passport/Login.aspx?ComeUrl=" + this.Page.Request.Url.ToString();
			this.Submit.Visible = false;
		}
		else
		{
			this.Submit.Visible = true;
		}
		if (!base.IsPostBack)
		{
		}
		if (base.Request.QueryString["msg_id"] == "" || base.Request.QueryString["requester_name"] == "" || base.Request.QueryString["request_date"] == "" || base.Request.QueryString["request_text"] == "")
		{
			base.Response.Write("出错啦！");
			base.Response.End();
		}
		this.SenderName.Text = base.Server.UrlDecode(base.Request.QueryString["requester_name"]);
		this.Request_date.Text = base.Server.UrlDecode(base.Request.QueryString["request_date"]);
		this.Request_Text.Text = base.Server.UrlDecode(base.Request.QueryString["request_text"]);
	}
	protected void Submit_Click(object sender, EventArgs e)
	{
		if (this.CheckValidateCode())
		{
			int m_ID = Convert.ToInt32(base.Server.HtmlEncode(base.Request.QueryString["msg_id"]));
			string userName = base.user.UserName;
			int userID = base.user.UserID;
			string m_Content = base.Server.HtmlEncode(this.MsgArea.Text);
			Shop_Message shop_Message = new Shop_Message();
			if (shop_Message.ReplayMessage(m_Content, userID, m_ID, userName))
			{
				if (base.Request["msgType"] != null && base.Request["msgType"] == "Request")
				{
					base.Response.Redirect("Auction_Message.aspx?msgType=Request&productID=" + base.Request["RequestID"]);
				}
				else
				{
					base.Response.Redirect("Auction_Message.aspx?productID=" + base.Request["ProductID"]);
				}
			}
			else
			{
				this.err_tips.Text = "很抱歉，回复失败，请刷新后再回复,可能已经对留言回复或者那留言是自己的";
				this.err_tips.CssClass = "tips_wrong";
			}
		}
		else
		{
			this.err_tips.Text = "验证码错误,请重新输入";
			this.err_tips.CssClass = "tips_wrong";
		}
	}
	public bool CheckValidateCode()
	{
		return string.Compare(this.Session["CheckCode"].ToString().ToLower(), this.CheckCode.Text.ToLower(), true) == 0;
	}
}
